<template>
  <!-- pages/huiyuanxinxi/huiyuanxinxi.wxml -->
  <view class="page">
    <view class="hy_">
      <view>头像</view>
      <image class="hy_tx_img" :src="hyxx.img"></image>
    </view>
    <view class="hy_">
      <view>昵称</view>
      <view class="hy_text">{{ hyxx.name }}</view>
    </view>
    <view class="hy_">
      <view>手机号</view>
      <view class="hy_text">{{ hyxx.number }}</view>
    </view>
    <view class="hy_">
      <view>生日</view>
      <view class="hy_text">{{ hyxx.shengri }}</view>
    </view>
    <view class="hy_">
      <view>性别</view>
      <view class="hy_text">{{ hyxx.sex }}</view>
    </view>
    <view class="hy_">
      <view>会员等级</view>
      <view class="hy_text">{{ hyxx.hydj }}</view>
    </view>
    <view class="hy_">
      <view>会员卡号</view>
      <view class="hy_text">{{ hyxx.hyID }}</view>
    </view>

    <view class="hy_qy">会员权益：{{ hyqy }}</view>

    <button @tap="gotoEditPage" class="hy_xgxx">
      <view>修改信息</view>
    </button>
  </view>
</template>

<script>
// pages/huiyuanxinxi/huiyuanxinxi.js
import {userindex} from "@/common/api";
var app = getApp();
export default {
  data() {
    return {
      hyqy: '商品无折扣、包座卡无折扣、桌台时长无折扣、桌台次卡无折扣、桌台消费折扣无折扣',
      hyxx: {
        img: '/static/pages/img/三角形.png',
        name: '微信用户',
        number: '12345678901',
        shengri: '1900-01-01',
        sex: '保密',
        hydj: '普通会员',
        hyID: '202404105916001431'
      },
      userinfo: {}
    };
  }
  /**
   * 生命周期函数--监听页面加载
   */,
  onLoad(options) {
    this.userinfo = JSON.parse(options.info);
    this.setData({
      hyxx: {
        img: this.userinfo.avatar_url,
        name: this.userinfo.nickname,
        number: this.userinfo.mobile,
        shengri: this.userinfo.both,
        sex: (this.userinfo.sex == 1 ? '男' : '女'),
        hydj:  this.userinfo.user_cash_grade_name,
        hyID: this.userinfo.user_card_no
      }
    });
    console.log('options', JSON.parse(options.info))
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.loginstatus = app.globalData.loginstatus;

    if (this.loginstatus == 2) {
      userindex(res => {
        this.userinfo=res.data.data.info;
        this.hyxx =  {
          img: res.data.data.info.avatar_url,
          name: res.data.data.info.nickname,
          number: res.data.data.info.mobile,
          shengri: res.data.data.info.both,
          sex: (res.data.data.info.sex== 1 ? '男' : '女'),
          hydj: res.data.data.info.user_cash_grade_name,
          hyID: res.data.data.info.user_card_no,
        }
        console.log("userindex", res)
      })
    }
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {
  },
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
  },
  methods: {
    gotoEditPage: function () {
      var that = this;
      uni.navigateTo({
        url:
            '/packageA/xiugaixinxi/xiugaixinxi?hyqy=' +
            that.hyqy +
            '&img=' +
            that.hyxx.img +
            '&name=' +
            that.hyxx.name +
            '&number=' +
            that.hyxx.number +
            '&shengri=' +
            that.hyxx.shengri +
            '&sex=' +
            this.userinfo.sex +
            '&hydj=' +
            that.hyxx.hydj +
            '&hyID=' +
            that.hyxx.hyID
      });
    }
  }
};
</script>
<style>
.page {
  background-color: rgb(238, 237, 237, 0.5);
  height: 100vh;
}

.hy_ {
  display: flex;
  justify-content: space-between; /* 子元素之间平均分布在容器中 */
  padding: 40rpx 60rpx 40rpx 60rpx;
  background-color: rgb(255, 255, 255);
  align-items: center; /* 垂直居中 */
  border-bottom: 1rpx solid rgb(238, 237, 237, 0.5);
}

.hy_tx_img {
  width: 80rpx;
  height: 80rpx;
  background-color: aqua;
}

.hy_text {
  font-size: 32rpx;
  color: rgb(92, 92, 92);
}

.hy_qy {
  font-size: 23rpx;
  color: rgb(92, 92, 92);
  margin: 40rpx 40rpx 40rpx 40rpx;
}

.hy_xgxx {
  background-color: rgb(70, 69, 69);
  height: 100rpx;
  margin: 40rpx 40rpx 40rpx 40rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgb(255, 255, 255);
  border-radius: 5px; /* 圆角设置为20px */
}
</style>
